package acm.深度优先遍历;

import java.util.Scanner;

public class L {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int count = sc.nextInt();
        while (count-- > 0) {
            int n=sc.nextInt();
            int m=sc.nextInt();
            System.out.println(fun(n,m,sc.nextInt(),sc.nextInt(),n*m-1,new boolean[n][m]));
        }
//
//        int fun = fun(5, 4, 0, 0, 19, new boolean[5][4]);
    }
    /**
     * 相当于走了n*m-1步，且没有重复的情况
     */
    public static int fun(int n,int m,int x,int y,int rest,boolean[][] map){
        if (x>=n||x<0||y>=m||y<0||map[x][y]){
            return 0;
        }
        if (rest==0){
            return 1;
        }
        map[x][y]=true;
        int res=fun(n,m,x+1,y+2,rest-1,map)
                +fun(n,m,x+1,y-2,rest-1,map)
                +fun(n,m,x-1,y+2,rest-1,map)
                +fun(n,m,x-1,y-2,rest-1,map)
                +fun(n,m,x+2,y+1,rest-1,map)
                +fun(n,m,x-2,y+1,rest-1,map)
                +fun(n,m,x+2,y-1,rest-1,map)
                +fun(n,m,x-2,y-1,rest-1,map);
        map[x][y]=false;
        return res;
    }
}
